import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { GImageBitmap } from "../../../../../com/mui/controls/GImageBitmap";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GangFightsResultPlayerData } from "../data/GangFightsResultPlayerData";
import { AvatarInfo } from "../../../resource/info/AvatarInfo";
import { AvatarType } from "../../../resource/info/AvatarType";
import { Language } from "../../../../../extend/language/Language";
import { CareerConfig } from "../../../resource/CareerConfig";
import { EntityUtil } from "../../../scene/layer/utils/EntityUtil";
import { Cache } from "../../../cache/Cache";
import { EBattleResult } from "../../../../../Message/Public/EBattleResult";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
type int = number;
//class GangFightsResultCellRenderer
    
    export  class GangFightsResultCellRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._bmpSelfBg = ResouceConst.getScaleBitmap("SelectedBg");
            this._bmpSelfBg.x = 0;
            this._bmpSelfBg.y = 0;
            this._bmpSelfBg.width = 576;
            this._bmpSelfBg.height = 74;
            this._bmpSelfBg.visible = false;
            this.addChild(this._bmpSelfBg);
            this.addChild(new GImageBitmap("GangFightsPlayerHeadBg.png", 0, 0));
            this._bmpHead = new GImageBitmap();
            ObjCreate.setObjAttri(this._bmpHead, 7, 7, -1, -1, this);
            this._tfName = ObjCreate.createTextField("", 92, 9, 180, 20, this);
            this._tfCareer = ObjCreate.createTextField("", 92, 26, 120, 20, this);
            this._tfTotalHurt = ObjCreate.createTextField("", 227, 26, 120, 20, this);
            this._tfWarfare = ObjCreate.createTextField("", 362, 26, 120, 20, this, GlobalStyle.textFormat6);
            this._tfKillNum = ObjCreate.createTextField("", 92, 43, 120, 20, this);
            this._tfTotalCure = ObjCreate.createTextField("", 227, 43, 120, 20, this);
            this._tfMark = ObjCreate.createTextField("", 362, 43, 120, 20, this);
            this._bmpResult = new Object /* flash.display.Bitmap */();
            this._bmpResult.x = 497;
            this._bmpResult.y = 14;
            this.addChild(this._bmpResult);
            LoaderHelp.addResCallBack(ResFileConst.arena, this.onResCompl);
            return;
        }

        /* internal  */onResCompl(): void
        {
            this._isResCompl = true;
            this.updateView();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            if (typeof arg1 === "gangfightsresultplayerdata") 
            {
                this._playerResult = arg1 as GangFightsResultPlayerData;
                this.updateView();
            }
            return;
        }

        /* internal  */updateView(): void
        {
            if (this._playerResult && this._isResCompl) 
            {
                this._bmpHead.imgUrl = AvatarInfo.getPlayerAvatarName(this._playerResult.playerResult.camp, this._playerResult.playerResult.sex, AvatarType.BIG, this._playerResult.playerResult.avatarId);
                this._tfName.text = Language.getString(44580) + this._playerResult.playerResult.name;
                this._tfWarfare.text = Language.getString(44581) + this._playerResult.playerResult.warfare.toString();
                this._tfCareer.text = Language.getString(44582) + CareerConfig.instance.getInfoByCode(this._playerResult.playerResult.career).name;
                this._tfTotalHurt.text = Language.getString(44583) + this._playerResult.playerResult.totalHurt.toString();
                this._tfTotalCure.text = Language.getString(44584) + this._playerResult.playerResult.totalCure.toString();
                this._tfKillNum.text = Language.getString(44585) + this._playerResult.playerResult.killNum.toString();
                this._tfMark.htmlText = Language.getString(44586) + this._playerResult.playerResult.mark.toString() + this.getAddMarkHtml(this._playerResult.playerResult.markAdd);
                if (EntityUtil.equal(this._playerResult.playerResult.entityId, Cache.instance.role.entityInfo.entityId)) 
                {
                    this._tfName.setTextFormat(GlobalStyle.textFormatGreen);
                    this._tfCareer.setTextFormat(GlobalStyle.textFormatGreen);
                    this._tfTotalHurt.setTextFormat(GlobalStyle.textFormatGreen);
                    this._tfTotalCure.setTextFormat(GlobalStyle.textFormatGreen);
                    this._tfKillNum.setTextFormat(GlobalStyle.textFormatGreen);
                    this._bmpSelfBg.visible = true;
                }
                else 
                {
                    this._tfName.setTextFormat(GlobalStyle.textFormat1);
                    this._tfCareer.setTextFormat(GlobalStyle.textFormat1);
                    this._tfTotalHurt.setTextFormat(GlobalStyle.textFormat1);
                    this._tfTotalCure.setTextFormat(GlobalStyle.textFormat1);
                    this._tfKillNum.setTextFormat(GlobalStyle.textFormat1);
                    this._bmpSelfBg.visible = false;
                }
                if (this._playerResult.battleResult.value() != EBattleResult._EBattleResultWin) 
                {
                    this._bmpResult.bitmapData = GlobalClass.getBitmapData(ImagesConst.ArenaLose);
                }
                else 
                {
                    this._bmpResult.bitmapData = GlobalClass.getBitmapData(ImagesConst.ArenaWin);
                }
            }
            return;
        }

        /* internal  */getAddMarkHtml(arg1: int): string
        {
            if (arg1 >= 0) 
            {
                return "(<font color = \'#00FF00\' size = \'14\'>+" + arg1 + "</font>)";
            }
            return "(<font color = \'#ff5b5b\' size = \'14\'>-" + Math.abs(arg1) + "</font>)";
        }

        /* internal */ /* var */_bmpSelfBg: ScaleBitmap;

        /* internal */ /* var */_bmpHead: GImageBitmap;

        /* internal */ /* var */_tfName: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfCareer: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfTotalHurt: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfWarfare: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfKillNum: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfTotalCure: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfMark: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfTeamMark: Object /* flash.text.TextField */;

        /* internal */ /* var */_bmpResult: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_playerResult: GangFightsResultPlayerData;

        /* internal */ /* var */_isResCompl: Boolean=false;
    }
